<?php

namespace app\common\model;

class ShopStore extends BaseModel
{
    // 关联SystemUser查询
    public function systemuser(){
        return $this->belongsTo('SystemUser','admin_id');
    }
    
    protected $append = ['full_address'];
    protected function getFullAddressAttr($val,$data){
        return $data['province'].$data['city'].$data['area'].$data['address'];
    }
    
    protected function getSiteUrlAttr($val,$data){
        return "/admin/Platform/index.html?store_id={$data['id']}&store_name={$data['name']}";
    }

    protected function getLogoAttr($val){
        return $this->getImgUrl($val);
    }

    protected function users(){
        return $this->belongsTo(SystemUser::class,'id','store_id');
    }

    public function user(){
        return $this->hasMany(User::class,'store_id','id');
    }

    public function order(){
        return $this->hasMany(ShopOrder::class,'store_id','id');
    }
}
